function RS = report_outcome(OO, ns, ss_ind, ...
    ssolve_market_all, nnon_converge_all, ssolve_market, nnon_converge,...
    D, K, N, D_enroll_st, pr_y, alpha, B1_c, beta_c, T1, B2_c,...
    fit_off_st, fit_off_ist, resource_y1, T2)
% indices = 1,..., N.ist
ind_N = find(ssolve_market_all==1 & nnon_converge_all==0 & fit_off_ist==0);
M = length(unique(D.mkt(ind_N)));
ind_major = find(ssolve_market_all==1 & nnon_converge_all==0 & fit_off_ist==0 & D.major==1);
ind_minor = find(ssolve_market_all==1 & nnon_converge_all==0 & fit_off_ist==0 & D.major==0);

if length(ind_minor)~= M
    disp('ERROR: fringe firm indexing wrong')
end

% indices = 1,..., N.st
ind_M = find(ssolve_market==1 & nnon_converge==0 & fit_off_st==0);
M_temp = length(ind_M);

if M~=M_temp
    disp('ERROR: market indexing wrong')
end

%%
% store % changes in the outcomes relative to baseline
RS.p1_vec       = zeros(ns,1);
RS.p2_vec       = zeros(ns,1);
RS.ratio_vec    = zeros(ns,1);
RS.n_vec        = zeros(ns,1);
RS.enroll_vec   = zeros(ns,1);
RS.welfare_vec  = zeros(ns,1);
RS.welfare_low  = zeros(ns,1);
RS.welfare_mid  = zeros(ns,1);
RS.welfare_high = zeros(ns,1);
RS.profit_vec   = zeros(ns,1);
RS.profit_major = zeros(ns,1);
RS.profit_minor = zeros(ns,1);
RS.each_minor   = zeros(ns,1);
RS.mkts         = zeros(ns,1);
RS.fsolve       = zeros(ns,1);
RS.p1_change_major  = zeros(ns,1);
RS.p1_change_minor  = zeros(ns,1);
RS.Ep2_change_major = zeros(ns,1);
RS.Ep2_change_minor = zeros(ns,1);
RS.Ep_ratio_major = zeros(ns,1);
RS.Ep_ratio_minor = zeros(ns,1);

% for each ss, in computing means, discard outliers 
lq_ini=0.01;
uq_ini=0.99;

% eqm at the baseline cost estimate
p1_eq            = OO(ss_ind).p1_cf; % N.ist x 1
p2_eq            = OO(ss_ind).p2_cf; % N.ist x KM
n_eq             = OO(ss_ind).n_cf;  %N.st x 1
profit_eq        = OO(ss_ind).profit_cf; % N.ist x 1
non_converge_all = OO(ss_ind).non_converge_all_cf; % N.ist x 1
solve_market_all = OO(ss_ind).solve_market_all_cf; % N.ist x 1
fsolve_all       = OO(ss_ind).fsolve_all_cf; % N.ist x 1
EV_y             = OO(ss_ind).EV_y_cf; % N.st x N_y
enrollment_eq    = OO(ss_ind).enrollment_cf; % N.st x 1
enrollment_m_eq  = OO(ss_ind).enrollment_m_cf; % N.st x 1
enrollment_f_eq  = OO(ss_ind).enrollment_f_cf; % N.st x 1
non_converge     = OO(ss_ind).non_converge_cf; % N.st x 1
solve_market     = OO(ss_ind).solve_market_cf; % N.st x 1
rs_share_eq      = OO(ss_ind).rs_share_cf;  % N.ist x 1

s1_mkt_eq = OO(ss_ind).s1_mkt_cf;

for ss=1:ns

    if ss==ss_ind % all changes are computed as zero by definition, so distribution is degenerate
        lq=0;
        uq=1;
    else
        lq=lq_ini;
        uq=uq_ini;
    end
    
    p1_cf         = OO(ss).p1_cf;
    p2_cf         = OO(ss).p2_cf;
    n_cf          = OO(ss).n_cf;
    profit_cf     = OO(ss).profit_cf;
    EV_y_cf       = OO(ss).EV_y_cf;
    enrollment_cf = OO(ss).enrollment_cf;
    enrollment_m_cf = OO(ss).enrollment_m_cf;
    enrollment_f_cf = OO(ss).enrollment_f_cf;
    fsolve_all_cf = OO(ss).fsolve_all_cf;
    rs_share_cf = OO(ss).rs_share_cf;

    s1_mkt_cf = OO(ss).s1_mkt_cf;

    %% fsolve
    frate = 100*sum(fsolve_all_cf(ind_N))/length(ind_N);

    %% outcomes reported at the insurer-market level
    % changes in p1
    p1_change = 100*(p1_cf-p1_eq)./p1_eq; % N.ist x 1

    p1_change_major = cndtl_mean(p1_change, ind_major, lq, uq);
    p1_change_minor = cndtl_mean(p1_change, ind_minor, lq, uq);
    p1_change = cndtl_mean(p1_change, ind_N, lq, uq);

    % change in p2
    p2_change = 100*(p2_cf-p2_eq)./p2_eq; % N.ist x KM
    Ep2_change = sum(p2_change.*D.pr_s_m,2); % N.ist x 1

    Ep2_change_major = cndtl_mean(Ep2_change, ind_major, lq, uq);
    Ep2_change_minor = cndtl_mean(Ep2_change, ind_minor, lq, uq);
    Ep2_change = cndtl_mean(Ep2_change, ind_N, lq, uq);

    % change in p2/p1
    KM = size(D.pr_s_m,2);
    p_ratio_eq = p2_eq./repmat(p1_eq, 1, KM); % N.ist x K
    p_ratio_cf = p2_cf./repmat(p1_cf, 1, KM); % N.ist x K
    p_ratio_change = 100*(p_ratio_cf-p_ratio_eq)./p_ratio_eq;
    Ep_ratio_change = sum(p_ratio_change.*D.pr_s_m,2); % N.ist x 1

    Ep_ratio_major = cndtl_mean(Ep_ratio_change, ind_major, lq, uq);
    Ep_ratio_minor = cndtl_mean(Ep_ratio_change, ind_minor, lq, uq);
    Ep_ratio_change = cndtl_mean(Ep_ratio_change, ind_N, lq, uq);

    % change in insurer profit
    profit_change = 100*(profit_cf-profit_eq)./profit_eq; % N.ist x 1;

    profit_change_major = cndtl_mean(profit_change, ind_major, lq, uq);
    profit_change_minor = cndtl_mean(profit_change, ind_minor, lq, uq);
    profit_change_all   = cndtl_mean(profit_change, ind_N, lq, uq);

    % change in the profit share of rate adjustment cost 
    rs_change = 100*(rs_share_cf-rs_share_eq)./rs_share_eq; % N.ist x 1;

    rs_change_major = cndtl_mean(rs_change, ind_major, lq, uq);
    rs_change_minor = cndtl_mean(rs_change, ind_minor, lq, uq);
    rs_change_all   = cndtl_mean(rs_change, ind_N, lq, uq);

    %% outcomes reported at the market level
    % changes in enrollment
    enrollment_change = 100*(enrollment_cf-enrollment_eq)./enrollment_eq; % N.st x 1
    enrollment_change = cndtl_mean(enrollment_change, ind_M, lq, uq);

    % changes in enrollment - total from all majors
    enrollment_m_change = 100*(enrollment_m_cf-enrollment_m_eq)./enrollment_m_eq; % N.st x 1
    enrollment_m_change = cndtl_mean(enrollment_m_change, ind_M, lq, uq);

    % changes in enrollment - total from all fringes
    enrollment_f_change = 100*(enrollment_f_cf-enrollment_f_eq)./enrollment_f_eq; % N.st x 1
    enrollment_f_change = cndtl_mean(enrollment_f_change, ind_M, lq, uq);

    % changes in per-fringe enrollment
    enrollment_per_f_eq = enrollment_f_eq./n_eq;
    enrollment_per_f_cf = enrollment_f_cf./n_cf;
    enrollment_per_f_change = 100*(enrollment_per_f_cf-enrollment_per_f_eq)./enrollment_per_f_eq;
    enrollment_per_f_change = cndtl_mean(enrollment_per_f_change, ind_M, lq, uq);

    % changes in # fringe entrants.
    n_change = 100*(n_cf-n_eq)./n_eq; % N.st x 1
    n_change = cndtl_mean(n_change, ind_M, lq, uq);

    % change in consumer welfare
    EV_change = exp((EV_y_cf-EV_y)/(alpha*(B1_c+(beta_c^T1)*B2_c))); % N.st x N_y, 1+delta
    EV_change = 100*(EV_change-1); % 100*delta, express the change in % terms
    EV_change_all    = EV_change*pr_y; % N.st x 1

    % - measured in per-enrollee terms 
    EV_change_all_insured = EV_change_all./enrollment_eq; % N.st x 1

    EV_change_all = cndtl_mean(EV_change_all, ind_M, lq, uq);
    EV_change_all_insured = cndtl_mean(EV_change_all_insured, ind_M, lq, uq);

    %% save result
    RS.p1_vec(ss)       = p1_change;
    RS.p2_vec(ss)       = Ep2_change;
    RS.ratio_vec(ss)    = Ep_ratio_change;
    RS.ratio_major(ss)    = Ep_ratio_major;
    RS.ratio_minor(ss)    = Ep_ratio_minor;

    RS.n_vec(ss)        = n_change;
    RS.enroll_vec(ss)   = enrollment_change;
    RS.welfare_vec(ss)  = EV_change_all;
    RS.welfare_vec_insured(ss)  = EV_change_all_insured;
    RS.profit_vec(ss)   = profit_change_all;
    RS.profit_major(ss) = profit_change_major;
    RS.profit_minor(ss) = profit_change_minor;
    
    RS.fsolve(ss)       = frate;
    RS.p1_change_major(ss)  = p1_change_major;
    RS.p1_change_minor(ss)  = p1_change_minor;
    RS.Ep2_change_major(ss) = Ep2_change_major;
    RS.Ep2_change_minor(ss) = Ep2_change_minor;

    RS.enroll_m_vec(ss)     = enrollment_m_change;
    RS.enroll_f_vec(ss)     = enrollment_f_change;
    RS.enroll_per_f_vec(ss) = enrollment_per_f_change;

    RS.rs_change_vec(ss) = rs_change_all;
    RS.rs_change_major_vec(ss) = rs_change_major;
    RS.rs_change_minor_vec(ss) = rs_change_minor;

    ind_N_ss = find(OO(ss).solve_market_all_cf==1 ...
        & OO(ss).non_converge_all_cf==0 ...
        & fit_off_ist==0);
    RS.mkts(ss) = length(unique(D.mkt(ind_N_ss)));
end

